package com.distributed.kv.dto;

import java.time.LocalDate;

/**
 * Group By查询响应对象
 */
public class GroupByResponse {
    
    /**
     * 按日期分组的访问统计
     */
    public static class DailyAccessStats {
        private LocalDate date;
        private String value;
        private Long totalAccessCount;
        private Long recordCount;
        
        public DailyAccessStats() {}
        
        public DailyAccessStats(LocalDate date, String value, Long totalAccessCount, Long recordCount) {
            this.date = date;
            this.value = value;
            this.totalAccessCount = totalAccessCount;
            this.recordCount = recordCount;
        }
        
        public LocalDate getDate() {
            return date;
        }
        
        public void setDate(LocalDate date) {
            this.date = date;
        }
        
        public String getValue() {
            return value;
        }
        
        public void setValue(String value) {
            this.value = value;
        }
        
        public Long getTotalAccessCount() {
            return totalAccessCount;
        }
        
        public void setTotalAccessCount(Long totalAccessCount) {
            this.totalAccessCount = totalAccessCount;
        }
        
        public Long getRecordCount() {
            return recordCount;
        }
        
        public void setRecordCount(Long recordCount) {
            this.recordCount = recordCount;
        }
    }
    
    /**
     * 按值分组的统计
     */
    public static class ValueStats {
        private String value;
        private Long totalAccessCount;
        private Long recordCount;
        private Double avgAccessCount;
        
        public ValueStats() {}
        
        public ValueStats(String value, Long totalAccessCount, Long recordCount) {
            this.value = value;
            this.totalAccessCount = totalAccessCount;
            this.recordCount = recordCount;
            this.avgAccessCount = recordCount > 0 ? (double) totalAccessCount / recordCount : 0.0;
        }
        
        public String getValue() {
            return value;
        }
        
        public void setValue(String value) {
            this.value = value;
        }
        
        public Long getTotalAccessCount() {
            return totalAccessCount;
        }
        
        public void setTotalAccessCount(Long totalAccessCount) {
            this.totalAccessCount = totalAccessCount;
        }
        
        public Long getRecordCount() {
            return recordCount;
        }
        
        public void setRecordCount(Long recordCount) {
            this.recordCount = recordCount;
        }
        
        public Double getAvgAccessCount() {
            return avgAccessCount;
        }
        
        public void setAvgAccessCount(Double avgAccessCount) {
            this.avgAccessCount = avgAccessCount;
        }
    }
    
    /**
     * 按日期分组的统计
     */
    public static class DateStats {
        private LocalDate date;
        private Long totalAccessCount;
        private Long recordCount;
        private Double avgAccessCount;
        
        public DateStats() {}
        
        public DateStats(LocalDate date, Long totalAccessCount, Long recordCount) {
            this.date = date;
            this.totalAccessCount = totalAccessCount;
            this.recordCount = recordCount;
            this.avgAccessCount = recordCount > 0 ? (double) totalAccessCount / recordCount : 0.0;
        }
        
        public LocalDate getDate() {
            return date;
        }
        
        public void setDate(LocalDate date) {
            this.date = date;
        }
        
        public Long getTotalAccessCount() {
            return totalAccessCount;
        }
        
        public void setTotalAccessCount(Long totalAccessCount) {
            this.totalAccessCount = totalAccessCount;
        }
        
        public Long getRecordCount() {
            return recordCount;
        }
        
        public void setRecordCount(Long recordCount) {
            this.recordCount = recordCount;
        }
        
        public Double getAvgAccessCount() {
            return avgAccessCount;
        }
        
        public void setAvgAccessCount(Double avgAccessCount) {
            this.avgAccessCount = avgAccessCount;
        }
    }
}